import { MyRequest, MockRequest } from "@/utils/http";

//请求首页三级分类列表
export const getBaseCategoryListRequest = () => {
  return MyRequest.get("/api/product/getBaseCategoryList");
};

//请求Mock banner数据
export const getMockBannerList = () => {
  return MockRequest.get("/banner");
};

//请求Mock floor数据
export const getMockFloorList = () => {
  return MockRequest.get("/floor");
};

//请求search 数据
export const getSearchListRequest = (params) => {
  return MyRequest.post("/api/list", params);
};

//请求detail数据
export const getDetailListRequest = (skuId) => {
  return MyRequest.get(`/api/item/${skuId}`);
};

//添加购物车数据 或对已有商品进行数量改动
export const getaddCartRequest = ({ skuId, skuNum }) => {
  return MyRequest.post(`/api/cart/addToCart/${skuId}/${skuNum}`);
};

//获取购物车列表
export const getshopCartListRequest = () => {
  return MyRequest.get("/api/cart/cartList");
};

//修改单个商品的选中状态
export const changeCheckedRequest = ({ skuId, isChecked }) => {
  return MyRequest.get(`/api/cart/checkCart/${skuId}/${isChecked}`);
};

//修改所有购物车商品选中状态
export const changeCheckedAllRequest = (isChecked, skuIdList) => {
  return MyRequest.post(`/api/cart/batchCheckCart/${isChecked}`, skuIdList);
};

//删除单个商品信息请求
export const deleteCartRequest = (skuId) => {
  return MyRequest.delete(`/api/cart/deleteCart/${skuId}`);
};

//删除所有已选择的商品请求
export const deleteCartAllRequest = (skuIdList) => {
  return MyRequest.delete("/api/cart/batchDeleteCart", {
    data: skuIdList,
  });
};

//获取注册验证码
export const getCodeRequest = (phone) => {
  return MyRequest.get(`/api/user/passport/sendCode/${phone}`);
};

//请求注册
export const registerRequest = (registerInfo) => {
  return MyRequest.post("/api/user/passport/register", registerInfo);
};

//登录请求
export const loginRequest = (userInfo) => {
  return MyRequest.post("/api/user/passport/login", userInfo);
};

//添加token权限校验获取用户信息请求
export const getUserInfoRequest = () => {
  return MyRequest.get("/api/user/passport/auth/getUserInfo");
};

//退出登录请求
export const loginOutRequest = () => {
  return MyRequest.get("/api/user/passport/logout");
};

//交易页获取请求
export const tradeInfoRequest = () => {
  return MyRequest.get("/api/order/auth/trade");
};

//请求用户地址
export const addressRequest = () => {
  return MockRequest.get("/address");
};

//提交订单请求
export const submitOrderRequest = (tradeNo, tradeInfo) => {
  return MyRequest.post(
    `/api/order/auth/submitOrder?tradeNo=${tradeNo}`,
    tradeInfo
  );
};

//获取订单支付信息
export const payDetailRequest = (orderId) => {
  return MyRequest.get(`/api/payment/weixin/createNative/${orderId}`);
};

//查看某个订单支付状态
export const payStatusRequest = (orderId) => {
  return MyRequest.get(`/api/payment/weixin/queryPayStatus/${orderId}`);
};

//获取我的订单数据
export const orderListRequest = ({ page, limit }) => {
  return MyRequest.get(`/api/order/auth/${page}/${limit}`);
};
